﻿#region Directives

using System;
using System.Web.UI.WebControls;
using ConnectIntegrationHub.WebService.Common;

#endregion

namespace ConnectIntegrationHub.WebService
{
    public partial class Default : System.Web.UI.Page
    {
        #region Properties
        
        public Service Service
        {
            get;
            set;
        }
        
        #endregion Properties

        #region Protected Methods

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Common.Routines.getDebugMode())
            {
                this.Service = new Service(true);
                if (!this.IsPostBack)
                {
                    cmbxEnvironment.Items.Clear();
                    foreach (var configuration in this.Service.DeploymentSynchronizations)
                    {
                        cmbxEnvironment.Items.Add(new ListItem(configuration.Name, configuration.Id.ToString()));
                    }
                }
            }            
        }

        protected void btnIntegration_Click(object sender, EventArgs e)
        {
            if (cmbxEnvironment.SelectedValue.IsNullOrEmpty())
            {
                return;
            }

            this.Service.processDeploymentSynchronization(new Guid(cmbxEnvironment.SelectedValue));
        }

        #endregion Protected Methods
    }
}